// pages/adminBusiness/adminBusiness.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mycurrent: '未处理',
    list: [],
    uList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },
  MyonChange(e) {
    this.setData({
      mycurrent: e.detail.key,
    })
    // if (e.detail.key == '账号管理') {
    //   this.userList()
    // } else {
      this.getlist()
    // }
  },
  getlist: function() {
    var that = this
    wx.request({
      url: app.globalData.api + 'businessOrderForm/list',
      data: {
        "keyword": "",
        "orderBy": "",
        "status": this.data.mycurrent,
        "businessManagerId": "",
        "timeRange": "",
        "page": "",
        "rows": 99
      },
      header: {
        Authorization: wx.getStorageSync('token')
      },
      method: 'POST',
      success: function(res) {
        console.log(res)
        if (res.data.code == 200) {
          that.setData({
            list: res.data.data.businessOrderFormList
          })
          console.log(that.data.list)
        }else{
          that.setData({
            list: []
          })
        }

      }
    })
  },
  machin: (e) => {
    wx.navigateTo({
      url: '/pages/machining/machining?id=' + e.currentTarget.dataset.id
    })
  },
  machinDe: (e) => {
    wx.navigateTo({
      url: '/pages/machinDe/machinDe?id=' + e.currentTarget.dataset.id
    })
  },
  // userList: function() {
  //   var that = this
  //   wx.request({
  //     url: app.globalData.api + 'user/list',
  //     data: {
  //       page: 1,
  //       rows: 999,
  //       roleName: '业务经理'
  //     },
  //     method: 'POST',
  //     header: {
  //       Authorization: wx.getStorageSync('token')
  //     },
  //     success: function(res) {
  //       console.log(res)
  //       if (res.data.code == 200) {
  //         that.setData({
  //           uList: res.data.data.userList
  //         })
  //       }else{
  //         that.setData({
  //           uList: []
  //         })
  //       }
  //     }
  //   })
  // },
  deleUser: function(e) {
    var that = this
    wx.showModal({
      title: '提示',
      content: '确认删除?',
      success(res) {
        if (res.confirm) {
          wx.request({
            url: app.globalData.api + 'user/' + e.currentTarget.dataset.id,
            data: {},
            header: {
              Authorization: wx.getStorageSync('token')
            },
            method: 'DELETE',
            success: (res) => {
              if (res.data.code == 200) {
                wx.showToast({
                  title: '删除成功',
                })
                // that.userList()
              }
            }
          })
        }
      }
    })
  },
  edlitUser: function(e) {
    wx.navigateTo({
      url: '/pages/account/account?type=业务经理&id=' + e.currentTarget.dataset.id,
    })
  },
  addAccount: function() {
    wx.navigateTo({
      url: '/pages/account/account?type=业务经理'
    })
  },
  yseOk:function(e){
      wx.navigateTo({
        url: '/pages/machining/machining?id=' + e.currentTarget.dataset.id
      })
  },
  noOk: function (e) {
    var that = this
    
    wx.navigateTo({
      url: '/pages/business_ord_det/business_ord_det?id='+e.currentTarget.dataset.id,
    })
  },
  goImg(e){
    wx.request({
      url: app.globalData.api + 'designDiagram/findDesignDiagramStyleNumber/' + e.currentTarget.dataset.imgid,
      data: '',
      header: {
        Authorization: wx.getStorageSync('token')
      },
      success: function(res) {
        if(res.data.code == 200){
           wx.navigateTo({
          url: '/pages/details/details?id=' + res.data.data.id,
        })
        }else{
          wx.showModal({
            title: '提示',
            content: res.data.errorMsg,
          })
        }
       
      }
    })
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    this.getlist()
    // this.userList()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})